package com.carpool.service;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Rate extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws IOException, ServletException {
		
		DBOperation DBO = new DBOperation();
		boolean returnflag = false;
		int rate=0;
		int driverID=0;
		
		try {
			InputStream is = request.getInputStream();
			DataInputStream dis = new DataInputStream(is);
			rate = dis.readInt();
			driverID = dis.readInt();
			returnflag = DBO.rate(rate, driverID);
			DataOutputStream dos = new DataOutputStream(response
					.getOutputStream());
			dos.writeBoolean(returnflag);
			dos.flush();
			dos.close();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}


	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException {
doGet(request, response);
}

}
